package com.fundodoo.blog.drunk1;


import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;


/**
 * @author 醉探索戈壁
 */
@RestController
@SpringBootApplication
public class Drunk1Application {

    public static void main(String[] args) {
        SpringApplication.run(Drunk1Application.class, args);
    }

    @GetMapping(value = "demo1")
    public String fundodo1() {
        return "hello 醉探索戈壁->https://blog.fundodoo.com";
    }

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {
            System.out.println("来看看springboot 默认给我们提供的bean");
            String[] beanNames = ctx.getBeanDefinitionNames();
            Arrays.sort(beanNames);
            Arrays.stream(beanNames).forEach(System.out::println);
        };
    }
}
